package internal

import "slices"

func QuickSort(list []int) []int {
	if len(list) < 2 {
		return list
	}
	base := list[0:1]
	less := []int{}
	greater := []int{}
	for _, v := range list[1:] {
		if v <= base[0] {
			less = append(less, v)
		} else {
			greater = append(greater, v)
		}
	}

	return slices.Concat(QuickSort(less), base, QuickSort(greater))
}
